package cn.wolfcode.service.impl;

import cn.wolfcode.domain.OperateIntegralVo;
import cn.wolfcode.mapper.UsableIntegralMapper;
import cn.wolfcode.service.IUsableIntegralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by lanxw
 */
@Service
public class UsableIntegralServiceImpl implements IUsableIntegralService {
    @Autowired
    private UsableIntegralMapper usableIntegralMapper;

    /**
     * 扣减可用积分
     * @param vo
     * @return
     */
    @Override
    public Boolean pay(OperateIntegralVo vo) {
        int effectCount = usableIntegralMapper.substractIntegral(vo.getPhone(), vo.getValue());
        return effectCount > 0;
    }

    /**
     * 退款积分
     * @param vo
     * @return
     */
    @Override
    public void refund(OperateIntegralVo vo) {
        usableIntegralMapper.incrIntegral(vo.getPhone(), vo.getValue());
    }


}
